﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DockSample;

namespace DockSample.CodeGenerator
{
    class JavaEntityGenerator
    {

        public  string JAVA_ENTITY_PACKAGE_PATH = SystemVar.JAVA_ENTITY_PACKAGE_PATH;

        public string fileName;
        public string diagramId;
        public string filePath;
        public string newEntityUrl;

        private JavaEntityInfo entityInfo;
        private JavaEntityTemplate template;
        private JavaEntityGenerator() { }
        public JavaEntityGenerator(ObjectDiagram objD)
        {
            this.entityInfo = new JavaEntityInfo(objD);
            this.template = new JavaEntityTemplate();
            this.fileName = StringUtil.GetFirstLetterUpperCase(objD.Name) + ".java";
            this.diagramId = objD.id;
            filePath = JAVA_ENTITY_PACKAGE_PATH + "\\" + fileName;
            this.newEntityUrl = SystemVar.newEntity_url + "/" + objD.Name + "/" + objD.id;

        }

        public void GenerateJavaEntity(){
            
            FileUtil.WriteFile(filePath, this.template.generate(this.entityInfo));
            
        }
    }
}
